package dkbta.ontology.values;

import dkbta.ontology.Validatable;
import dkbta.ontology.elements.Element;
import dkbta.ontology.elements.ElementType;

/**
 * A condition over an element's value
 * 
 * @author Uri Kanonov
 */
public abstract class ValueCondition implements Validatable{
	/** The possible values of the attribute the condition allows */
	protected final Values _allowedValues;

	/** The name of the associated element */
	protected final String _elementName;

	/** The type of the associated element */
	protected final ElementType _elementType;

	/**
	 * Constructs a value constraint based on the given element
	 * 
	 * @param elementName The name of the element the constraint is based on
	 * @param elementType The type of the element the constraint is based on
	 * @param possibleValues The possible values the constraint allows
	 */
	public ValueCondition(String elementName, ElementType elementType,
		Values possibleValues){
		_allowedValues = possibleValues;
		_elementName = elementName;
		_elementType = elementType;
	}

	/**
	 * Returns the name of the associated element
	 * 
	 * @return The name of the associated element
	 */
	public String getElementName(){
		return _elementName;
	}

	/**
	 * Returns the type of the associated element
	 * 
	 * @return The type of the associated element
	 */
	public ElementType getElementType(){
		return _elementType;
	}

	/**
	 * Checks whether a certain element instance meets the condition
	 * 
	 * @param e The instance
	 * @return Whether the certain element instance meets the condition
	 */
	public abstract boolean checkCondition(Element e);
}
